from nonebot.plugin import on_command
from nonebot.rule import to_me
from nonebot.typing import T_State
from nonebot.adapters import Bot, Event
from pydantic.tools import T

from ...dao import db_context
from ...model.user import User
from ...dao import user_dao

unbind = on_command("解除绑定", rule=to_me())

@unbind.handle()
async def get_qqid(bot:Bot,event:Event,state:T_State):
    qq_id= event.get_user_id()
    state["qq_id"]=qq_id

@unbind.got("check", prompt="请问您确定要解除已经绑定的学号吗？请回答是或否。")
async def handle_check(bot: Bot, event: Event, state: T_State):
    qq_id=state["qq_id"]
    check=state["check"]
    if check=="是":
        await user_dao.delete_user(qq_id)
        await unbind.send("解除绑定成功！")
    elif check=="否":
        await unbind.send("已取消解除。")